home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD ROM Paradise Collection 4
/
CD ROM Paradise Collection 4 1995 Nov.iso
/
win
/
rtfhelp.zip
/
RTFHCP85.C
< prev
next >
Wrap
Text File
|
1994-11-06
|
5KB
|
99 lines
/*
======================================================================
RTFHelp Windows Help Generation Tool
(C) Copyright 1994 by J. Hlavaty
RTFHCP85.c
CP850 to ANSI conversion
======================================================================
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "rtfhelp.h"
UCHAR CP850[256] = { // 0 1 2 3 4 5 6 7 8 9
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 00
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 10
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 20
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 30
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 40
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 50
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 60
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 70
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 80
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 90
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 100
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 110
// C, u" *
0, 0, 0, 0, 0, 0, 0, 0, 199, 252, // 120
//------------------- 0 1 2 3 4 5 6 7 8 9 -----------
// e' a^ a" a\ ao c, e^ e" e\ i" *
233, 226, 228, 224, 229, 231, 234, 235, 232, 239, // 130
// BUG WARNING: I'm using '\' as the 'grave accent' marker
// This is also the C continuation character and caused ten
// characters of our table to disappear if it was the last
// character on a line!
// i^ i\ A" Ao E' ae AE o^ o" o\ *
238, 236, 196, 197, 201, 230, 198, 244, 246, 242, // 140
// u^ u\ y" O" U" cnt lb yen - - *
251, 249, 255, 214, 220, 162, 163, 165, 0, 0, // 150
// a' i' o' u' n~ N~ a_ o_ (?) - *
225, 237, 243, 250, 241, 209, 170, 186, 191, 173, // 160
// not 1/2 1/4 (!) << >> *
172, 189, 188, 161, 171, 187, 0, 0, 0, 0, // 170
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 180
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 190
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 200
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 210
// (sz) (par) *
0, 0, 0, 0, 0, 223, 182, 0, 0, 0, // 220
// (m) *
181, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 230
// +- sup. 0 *
0, 177, 0, 0, 0, 0, 0, 0, 176, 0, // 240
// sup. 2 uml. *
0, 0, 0, 252, 168, 0, // 250
} ;
int TranslateCPToANSI( int cp, char *str )
{
UCHAR ANSIcodepoint = 0 ;
UCHAR offset = 0 ;
while ( *str )
{
switch( cp )
{
case 850:
if ( 0 == CP850[*str] ) // if table entry is '0', don't change the original
;
else
{
offset = *str ; // get the current character
ANSIcodepoint = CP850[offset] ; // use codepoint as index into table
// NOTE: if the ANSI table above doesn't contain the given codepoint,
// then we are to leave it alone
if ( ANSIcodepoint ) // if we have a replacement character replace it
*str = ANSIcodepoint ;
}
break;
case 0:
// we have no code page or are looping through the first line of an
// unsupported codepage...
break;
default:
codepage = 0 ;
printf("RTFHELP: unsupported codepage '%d'\n", cp) ;
return FALSE ;
}
str++ ;
}
return TRUE ;
}